<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="/static/component/pear/css/pear.css" />
    <link rel="stylesheet" href="/static/admin/css/other/person.css" />
    <style>
        .layui-form-item{
            margin-top: 17px!important;
            margin-bottom: 17px!important;
        }
    </style>
</head>
<body class="pear-container">
<div class="layui-row layui-col-space10">
    <div class="layui-col-md3">
        <div class="layui-card">
            <div class="layui-card-body" style="padding: 25px;">
                <div class="text-center layui-text">
                    <div class="user-info-head" id="userInfoHead">
                        <img id="avatar" src="{{ .user.Avatar }}" width="115px" height="115px" alt="">
                    </div>
                    <h2 style="padding-top: 20px;font-size: 20px;">{{.user.RealName}}</h2>
                </div>
            </div>
            <div style="height: 45px;border-top: 1px whitesmoke solid;text-align: center;line-height: 45px;font-size: 13.5px;">
                <span>{{.user.Remark}}</span>
            </div>
        </div>
        <div class="layui-card">
            <div class="layui-card-header">
                登录记录
            </div>
            <div class="layui-card-body">
                <ul class="list">
                    {{range $k,$v := .info}}
                    <li  class="list-item"><span class="title" > {{$v.IpAddr}}  {{$v.Msg}}</span><span class="footer"> {{$v.LoginTime.Format "2006-01-02 15:04:05" }}</span></li>
                    {{end}}
                </ul>
            </div>
        </div>
    </div>
    <div class="layui-col-md9">
        <div class="layui-card">
            <div class="layui-card-header">个人信息</div>
            <div class="layui-card-body">
                <div class="layui-tab layui-tab-brief">
                    <div class="layui-tab-content">
                        <div class="layui-tab-item layui-show">
                            <form class="layui-form">
                                <input type="hidden" name="id" value="{{.user.ID}}">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">账号</label>
                                    <div class="layui-input-block">
                                        <input value="{{.user.LoginName}}" type="text" readonly name="username" lay-verify="title"
                                               autocomplete="off" disabled class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">姓名</label>
                                    <div class="layui-input-block">
                                        <input  value="{{.user.RealName}}"  type="text" name="real_name" lay-verify="title"
                                                autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">邮箱</label>
                                    <div class="layui-input-block">
                                        <input  value="{{.user.Email}}"  type="text" name="email" lay-verify="title"
                                                autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">电话</label>
                                    <div class="layui-input-block">
                                        <input  value="{{.user.Phone}}"  type="text" name="phone" lay-verify="title"
                                                autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">描述</label>
                                    <div class="layui-input-block">
                                        <textarea name="remark" class="layui-textarea">{{.user.Remark}}</textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="pear-btn pear-btn-primary pear-btn-sm" lay-submit lay-filter="user-update">修改资料</button>
                                        <button class="pear-btn pear-btn-sm edit-password">更改密码</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
<!--        <div class="layui-card">-->
<!--            <div class="layui-card-header">-->
<!--                我的文章-->
<!--            </div>-->
<!--            <div class="layui-card-body">-->
<!--                <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">-->
<!--                    <div class="layui-tab-content">-->
<!--                        <div class="layui-tab-item layui-show">-->
<!--                            <div class="layui-row layui-col-space10" style="margin: 15px;">-->
<!--                                <div class="layui-col-md1">-->
<!--                                    <img src="/static/admin/images/act.jpg"-->
<!--                                         style="width: 100%;height: 100%;border-radius: 5px;"/>-->
<!--                                </div>-->
<!--                                <div class="layui-col-md11" style="height: 80px;">-->
<!--                                    <div class="title">为什么程序员们愿意在GitHub上开源自己的成果给别人免费使用和学习？</div>-->
<!--                                    <div class="content">-->
<!--                                        “Git的精髓在于让所有人的贡献无缝合并。而GitHub的天才之处，在于理解了Git的精髓。”来一句我们程序员们接地气的话：分享是一种快乐~-->
<!--                                    </div>-->
<!--                                    <div class="comment">2020-06-12 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 评论 5 点赞 12 转发-->
<!--                                        4-->
<!--                                    </div>-->
<!--                                </div>-->
<!--                            </div>-->
<!--                            <div class="layui-row layui-col-space10" style="margin: 15px;">-->
<!--                                <div class="layui-col-md1">-->
<!--                                    <img src="/static/admin/images/act.jpg" style="width: 100%;height: 100%;border-radius: 5px;"/>-->
<!--                                </div>-->
<!--                                <div class="layui-col-md11" style="height: 80px;">-->
<!--                                    <div class="title">为什么程序员们愿意在GitHub上开源自己的成果给别人免费使用和学习？</div>-->
<!--                                    <div class="content">-->
<!--                                        “Git的精髓在于让所有人的贡献无缝合并。而GitHub的天才之处，在于理解了Git的精髓。”来一句我们程序员们接地气的话：分享是一种快乐~-->
<!--                                    </div>-->
<!--                                    <div class="comment">2020-06-12 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 评论 5 点赞 12 转发-->
<!--                                        4-->
<!--                                    </div>-->
<!--                                </div>-->
<!--                            </div>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
    </div>
</div>
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>
<script >
    layui.use(['element', 'jquery', 'layer','form'], function () {
        let $ = layui.jquery;
        let layer = layui.layer;
        let form = layui.form;

        $(".edit-password").click(function () {
            layer.open({
                type: 2,
                title: '修改密码',
                shade: 0.1,
                area: ['550px', '280px'],
                content: '/system/user/pwd'
            });
            return false;
        })


        $("#avatar").click(function () {
            layer.open({
                type: 2,
                title: '更换图片',
                shade: 0.1,
                area: ["900px", "500px"],
                content: '/system/user/uploadPage',
                btn: ['确定', '取消'],
                yes: function (index, layer) {
                    window['layui-layer-iframe' + index].submitForm();
                }
            });
        });

        form.on('submit(user-update)', function (data) {
            $.ajax({
                url: '/system/user/edit',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'POST',
                success: function (result) {
                    if (result.code == 200) {
                        layer.msg("修改成功", {icon: 1, time: 1000},function(){
                            location.reload();
                        });
                    } else {
                        layer.msg("修改失败", {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });
    })
</script>
</body>
</html>
